﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Imaginecup.gameState.recycling.Sprite;

namespace Imaginecup.recycling.Object.Menu
{
    public class RenderDrawer
    {
        private static RenderDrawer Instance;
        public static RenderDrawer GetInstance()
        {
            if(Instance == null)
                Instance = new RenderDrawer();
            return Instance;
        }
        private List<ISprite> AllSprite;

        private RenderDrawer()
        {
            AllSprite = new List<ISprite>();
        }

        public void Drawer(SpriteBatch spriteBatch, GameTime gameTime)
        {
            foreach (ISprite sprite in AllSprite)
            {
                sprite.Draw(spriteBatch, gameTime);
            }
        }
        
        public void AddSprite(ISprite sprite)
        {
            if(!AllSprite.Contains(sprite))
                AllSprite.Add(sprite);
        }
        public void RemoveSprite(ISprite sprite)
        {
            if (AllSprite.Contains(sprite))
                AllSprite.Remove(sprite);
        }
        public void Release()
        {
            AllSprite.Clear();
        }
    }
}
